package com.guo.boot.study.thread;

/**
 * @Auther Heart Guo
 * @Date 2021/12/23-14:04
 */
/*
    1、模拟网络延时：放大问题的发生性

* */
public class TestSleep implements Runnable {
    private int tickNums = 10;
    private boolean flag = true;

    @Override
    public void run() {
        while (flag){
            if(tickNums<=0){
                break;
            }

            //模拟延时
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            System.out.println(Thread.currentThread().getName()+"--拿到了第--"+tickNums--+"张票");
        }
    }

    public static void main(String[] args) {
        TestSleep sleep = new TestSleep();
        new Thread(sleep,"张三").start();
        new Thread(sleep,"李四").start();
        new Thread(sleep,"黄牛").start();
    }
}
